home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
virtmem.exe
/
VIRTUMEM.INT
< prev
next >
Wrap
Text File
|
1992-10-08
|
4KB
|
136 lines
Unit VirtuMem; {Virtual memory manager -modified LRU}
{$F+}
{$R+}
{$B-}
{$O-}
Interface
{THE FOLLOWING CONSTANTS, VARIABLES AND ROUTINES ARE MEANT TO BE USED BY
ANY PROGRAM. THEY ARE THE ESSENTIAL INTERFACE OF THE VIRTUMEM UNIT, ALONG
WITH SOME SUPPORT TO GET STATUS INFORMATION.}
Const
Null=0;
Clen=0;
Dirt=1;
Stay=2;
BookOpen:Boolean=FALSE;
VVersion=1.0;
VVersionDate='February 27, 1992';
Var
VMem :Boolean; {Virtual memory is active.}
NotSoRealTime :LongInt; {Number of calls to virtual memory system}
Missy :Integer; {Number of times a reference was not found in real memory}
NewCount :LongInt; {Number of calls to ANew}
DepossessCount:LongInt; {Number of calls to Depossess}
ExpandedCount :LongInt; {Number of times a read was done from an expanded memory page.}
SwapCount :LongInt; {Number of times an expanded memory page was swapped with a real memory page.}
Unstaycount :LongInt; {Number of calls to Unstay}
{Initialize Virtual memory system.}
{$IFDEF USEEMS}
Procedure OpenBook(EMSSuppress:Boolean);
{$ELSE}
Procedure OpenBook;
{$ENDIF}
{Allocate a virtual memory block.}
Function ANew(Size : Word):LongInt;
{Reference a virtual memory block.}
Function R(Virt : LongInt; Mucky : Integer):Pointer;
{Deallocate a virtual memory block.}
Procedure Depossess(var Virt:LongInt;Biggness:Word);
{Return the number of pages that are held in real memory.}
Function CountStay:Integer;
{Free a page that is held in real memory.}
Procedure UnStay(Virt : LongInt);
{Shut down the virtual memory system.}
Procedure CloseBook;
{THE FOLLOWING CONSTANTS, TYPES, VARIABLES AND ROUTINES ARE INCLUDED IN THE
INTERFACE SECTION OF VIRTUMEM ONLY BECAUSE THEY ARE ALSO USED BY SUCH
UNITS AS "SECONDAR" WHICH DO SOME LOW LEVEL MANIPULATION OF THE NORMAL
VIRTUMEM STRUCTURE. THESE ARE NOT NORMALLY USED BY OTHER PROGRAMMERS.}
Const
{$IFDEF DEBUG}
PageSize =1023;
{$ELSE}
PageSize =8191;
{$ENDIF}
MaxPage =511; {Max page number in memory resident table}
C =FALSE;
D =TRUE;
DirtyMarkup =512;
NoPage = 65535;
PagePerXPage=(16*1024) div (PageSize+1);
HighFreeListElement = 511;
Type
DataBlockPtr=^DataBlockArr;
DataBlockArr=Array[0..PageSize] of Byte;
PageFramePtr=^PageFrameRec;
PageFrameRec=
Record
Dirty :Boolean;
Priority :LongInt;
StayCount :Integer;
Data :DataBlockPtr;
Last :PageFramePtr;
{$IFDEF USEEMS}
LogicalPage:Word;
Offset :Word;
{$ENDIF}
PageNum :Integer;
End;
TableEntry =
Record
Frame : PageFramePtr;
DirtE : Boolean;
PageNum : Integer;
End;
Var
PageTable :Array[0..MaxPage] of TableEntry;
HighFrame :PageFramePtr;
HighPage :Integer;
PageInMem :Integer;
PgTable :File of TableEntry;
VirtualMemory :File;
Traver :PageFramePtr;
Bound :LongInt;
V :DataBlockArr;
{$IFDEF CALLPROF}
CallBin :Array[0..511] of LongInt;
{$ENDIF}
Procedure SetFreeList;
Procedure PageTableFlush;
Procedure VirtualMemoryFlush;
{$IFDEF VERYLARGE}
Procedure GetEntry(PageNumber : Integer);
{$ENDIF}
{$IFDEF USEEMS}
Function PageSegment(LogicalPageNum:Word):Word;
Procedure MapIn(LogicalPage:Word);
{$ENDIF}
Procedure UnsetFreeList;
Procedure Dumpossess;{Write the free list to the screen.}